package com.fire.security.service.impl;

import com.fire.security.domain.Result;
import com.fire.security.domain.User;
import com.fire.security.dto.*;
import com.fire.security.mapper.StatisticsMapper;
import com.fire.security.service.StatisticsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Service
public class StatisticsServiceImpl implements StatisticsService {
    @Autowired
    StatisticsMapper statisticsMapper;
    @Override
    public Result getArticlesRank(){
        List<ArticleViewRankDto> articleViewRankList = statisticsMapper.getArticlesRank();
        List<Integer> articleNumber = new ArrayList<>();
        List<String>  articleName = new ArrayList<>();
        for (ArticleViewRankDto articleViewRankDto : articleViewRankList) {
            articleName.add(articleViewRankDto.getArticleTitle());
            articleNumber.add(articleViewRankDto.getViewerNumber());
        }

        return Result.ok(new ListDto(articleName,articleNumber));
    }

    @Override
    public Result getUserCount() {
        List<UserCountDto> UserCountList = statisticsMapper.getUserCount();
        UserCountList.add(new UserCountDto("管理员人数",statisticsMapper.getAdminCount()));
        return Result.ok(UserCountList);
    }

    @Override
    public Result get7DaysReportCount() {
        List<ReportCountDto> ReportCountList = statisticsMapper.get7DaysReportCount();
        return Result.ok(ReportCountList);
    }

    @Override
    public Result getAllShopLocal() {
        List<ShopLocalDto> ShopLocalList = statisticsMapper.getAllShopLocal();
        return Result.ok(ShopLocalList);
    }
}
